import pandas as pd
import numpy as np
from jieba import analyse

df = pd.read_csv('../static/data/info_pre.csv')
keyword_list = [','.join(analyse.extract_tags(i.replace('.', ''), topK=5)) for i in df['description'].values.tolist()]
keyword_list = ','.join(keyword_list).split(',')
keyword_list = np.array(keyword_list)
df_keyword = pd.DataFrame(keyword_list).rename(columns={0: 'word'})
df_keyword = df_keyword.groupby('word').value_counts().reset_index().rename(columns={0: 'count'})
df_keyword.sort_values('count', ascending=False, inplace=True)
df_keyword.to_csv('../static/data/word.csv', index=False)
